package com.quasar.hpatient.bean.mine_case;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

import lib.quasar.context.BaseConstant;
import lib.quasar.recycler.model.MultModel;
import lib.quasar.util.LogUtil;
import lib.quasar.widget.photo.PhotoModel;

public final class MineCaseBean implements MultModel {

    private int id;
    private String medical_history_date;
    private String hospital_name;
    private String medical_title;
    private String json_content;
    private ArrayList<String> json_pic;

    public List<MinePictureBean> getList() {

        if (null == json_pic || json_pic.isEmpty())
            return null;

        final ArrayList<MinePictureBean> list = new ArrayList<>();
        list.clear();

        for (String temp : json_pic) {
            final MinePictureBean model = new MinePictureBean();
            model.setUrl(temp);
            list.add(model);
        }

        LogUtil.e("MineCaseBean", list.toString());
        return list;
    }

    @Override
    public int getMultType() {
        return (isPicture() ? MultModel.TYPE_0 : MultModel.TYPE_1);
    }

    public boolean isPicture() {
        return null != json_pic && !json_pic.isEmpty();
    }

    /******************************************************************************/

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getMedical_history_date() {
        return medical_history_date;
    }

    public String getDates() {
        return medical_history_date.substring(0, 10);
    }

    public void setMedical_history_date(String medical_history_date) {
        this.medical_history_date = medical_history_date;
    }

    public String getHospital_name() {
        return hospital_name;
    }

    public void setHospital_name(String hospital_name) {
        this.hospital_name = hospital_name;
    }

    public String getMedical_title() {
        return medical_title;
    }

    public void setMedical_title(String medical_title) {
        this.medical_title = medical_title;
    }

    public String getJson_content() {
        return json_content;
    }

    public void setJson_content(String json_content) {
        this.json_content = json_content;
    }

    public ArrayList<String> getJson_pic() {
        return json_pic;
    }

    public void setJson_pic(ArrayList<String> json_pic) {
        this.json_pic = json_pic;
    }

    /******************************************************************************/

    public static final class MinePictureBean implements PhotoModel, Parcelable {

        private String url;

        public void setUrl(String url) {
            this.url = url;
        }

        @Override
        public String getUrl() {
            return BaseConstant.API_URL + url;
        }

        @Override
        public String getUrlLittle() {
            return BaseConstant.API_URL + url;
        }

        public MinePictureBean() {
        }

        protected MinePictureBean(Parcel in) {
            url = in.readString();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(url);
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public static final Creator<MinePictureBean> CREATOR = new Creator<MinePictureBean>() {
            @Override
            public MinePictureBean createFromParcel(Parcel in) {
                return new MinePictureBean(in);
            }

            @Override
            public MinePictureBean[] newArray(int size) {
                return new MinePictureBean[size];
            }
        };
    }
}
